package com.gangquan360.smartadmin.module.order.saleorder.controller;

import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.module.order.saleorder.domain.dto.SaleOrderProductDTO;
import com.gangquan360.smartadmin.module.order.saleorder.domain.dto.SaleOrderProductQueryDTO;
import com.gangquan360.smartadmin.module.order.saleorder.service.SaleOrderProductService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * [ 送样表的产品 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-31 19:42:09
 * @since JDK1.8
 */
@RestController
@Api(tags = {"送样表的产品"})
public class SaleOrderProductController {

    @Autowired
    private SaleOrderProductService saleOrderProductService;

    @ApiOperation(value = "分页查询送样表的产品",notes = "@author wiggin")
    @PostMapping("/saleOrderProduct/page/query")
    public ResponseDTO<PageResultDTO<SaleOrderProductDTO>> queryByPage(@RequestBody SaleOrderProductQueryDTO queryDTO) {
        return saleOrderProductService.queryByPage(queryDTO);
    }

    @ApiOperation(value = "添加送样表的产品",notes = "@author wiggin")
    @PostMapping("/saleOrderProduct/add")
    public ResponseDTO<String> add(@RequestBody @Valid SaleOrderProductDTO addTO){
        return saleOrderProductService.add(addTO);
    }

    @ApiOperation(value="修改送样表的产品",notes = "@author wiggin")
    @PostMapping("/saleOrderProduct/update")
    public ResponseDTO<String> update(@RequestBody @Valid SaleOrderProductDTO updateDTO){
        return saleOrderProductService.update(updateDTO);
    }


    @ApiOperation(value="删除送样表的产品",notes = "@author wiggin")
    @GetMapping("/saleOrderProduct/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return saleOrderProductService.delete(id);
    }


    @ApiOperation(value="详情送样表的产品",notes = "@author wiggin")
    @GetMapping("/saleOrderProduct/detail/{id}")
    public ResponseDTO<SaleOrderProductDTO> detail(@PathVariable("id") Long id){
        return saleOrderProductService.detail(id);
    }
}
